{extend name="admin@publics/base"/}
{block name="title"}配置管理{/block}
{block name="body"}

<script>
//页面变量
_PAGE['adminConfig'] = {
};
/*==========控制器==========*/
Ext.define('admin.config.CURDViewController', {
	extend: 'Tg.tx.CURDViewController',
	alias: 'controller._adminConfigController',
});
/*==========模型==========*/
Ext.define('admin.config.CURDViewModel', {
	extend: 'Tg.tx.CURDViewModel',
	alias: 'viewmodel._adminConfigViewModel',
    //Data
    data:{
    	//权限
        _Auth:{
        	index	: {if condition="_CheckAuth('admin/Config/index')"}true{else/}false{/if},
        	add		: {if condition="_CheckAuth('admin/Config/add')"}true{else/}false{/if},
        	edit	: {if condition="_CheckAuth('admin/Config/edit')"}true{else/}false{/if},
        	del		: {if condition="_CheckAuth('admin/Config/del')"}true{else/}false{/if},
        },
        _Url:{
        	index	: _PATH['site']+'/admin/config/index',
        	add		: _PATH['site']+'/admin/config/add',
        	edit	: _PATH['site']+'/admin/config/edit',
        	del		: _PATH['site']+'/admin/config/del',
        },
        //操作视图
        _Ext:{
        	index	: 'admin.config.index',
        	serch	: 'admin.config.serch',
        	add		: 'admin.config.updata',
        	edit	: 'admin.config.updata',
        	del		: 'admin.config.del',
        },
		_Pk:'id',
    },
    //Store
	stores: {
		_MainStore: {
			sorters: [{property: 'id',direction: 'desc'}],
			pageSize: 20,
			remoteSort: true,
			remoteFilter:true,
			proxy: {
				type: 'ajax',
				api: {read:_PATH['site']+'/admin/config/index'},
				actionMethods:{read: "POST"},
				reader: {type: 'json',rootProperty: 'rows',totalProperty: 'total'}
			},
		}
	},
});
/*==========视图==========*/
//列表
Ext.define('admin.config.index', {
	extend: 'Tg.tx.CURDList',
	alias: 'widget.admin_Config_index',
	requires: [
		'admin.config.CURDViewController',
		'admin.config.CURDViewModel',
	],
	controller: '_adminConfigController',
	viewModel: '_adminConfigViewModel',
    _TbarLBefore:[
        {xtype: 'label',text: '配置管理',itemId:'_Tit',style: 'font-size:16px; padding-right:10px;margin-right: 10px;border-right: dotted 1px #ccc;'},
    ],
    items:[
		{
			xtype:'CURDListGrid',
			bind:{store:'{_MainStore}'},
			columns:[
        		{xtype:"actioncolumn",header:"更新",width: 50,iconCls:'tf tf-edit',align:'center',locked: true,handler: '_ColumnEdit',bind:{hidden:'{!_Auth.edit}'}},
				{xtype:"actioncolumn",header:"删除",width: 50,iconCls:'tf tf-del',align:'center',locked: true,handler: '_ColumnDel',bind:{hidden:'{!_Auth.del}'}},
				{dataIndex:'id', header :'主键', width :60, hidden:false, locked:true, sortable:true },
				{dataIndex:'name', header :'标识', width :120, hidden:false, locked:false, sortable:false },
				{dataIndex:'title', header :'名称', width :120, hidden:false, locked:false, sortable:false },
				{dataIndex:'group', header :'分组', width :80, hidden:false, locked:false, sortable:false, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {return _Res_Val(_Dictionary,'config_group', value);}},
				{dataIndex:'sort', header :'排序', width :60, hidden:false, locked:false, sortable:true },
				{dataIndex:'status', header :'状态', width :50, hidden:false, locked:false, sortable:true, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {return _Res_Val(_Dictionary,'sys_status', value);}},
				{dataIndex:'create_time', header :'创建时间', width :110, hidden:true, locked:false, sortable:true },
				{dataIndex:'update_time', header :'更新时间', width :110, hidden:true, locked:false, sortable:true },
			],
		}
	],
});

//搜索
Ext.define('admin.config.serch', {
	extend: 'Tg.tx.Window',
	alias: 'widget.admin_Config_serch',
	requires: [
		'admin.config.CURDViewController',
		'admin.config.CURDViewModel',
	],
	controller: '_adminConfigController',
	viewModel: '_adminConfigViewModel',
    title:'搜索',
	width:600,
	height:400,
    items:{
    	xtype:'CURDForm',
        items:[ 
			{items: [
				{fieldLabel: '主键', name: 's_id',xtype: "textfield", columnWidth: 0.5},
				{fieldLabel: '标识', name: 's_name',xtype: "textfield", columnWidth: 0.5},
			]},
			{items: [
				{fieldLabel: '名称', name: 's_title',xtype: "textfield", columnWidth: 0.5},
				{fieldLabel: '分组', name: 's_group',xtype: "combobox",displayField: "text",valueField: "value",store: {fields: ["text", "value"],data:_Dictionary['config_group']}, columnWidth: 0.5},
			]},
			{items: [
				{fieldLabel: '状态', name: 's_status',xtype: "combobox",displayField: "text",valueField: "value",store: {fields: ["text", "value"],data:_Dictionary['sys_status']}},
			]},
			{items: [
				{fieldLabel: '说明', name: 's_remark',xtype: "textfield"},
			]},
			{items: [
				{fieldLabel: '起始创建时间', name: 's_create_time_min',xtype: "datetimefield",columnWidth: 0.5},
				{fieldLabel: '截止创建时间', name: 's_create_time_max',xtype: "datetimefield",columnWidth: 0.5},
			]},
			{items: [
				{fieldLabel: '起始更新时间', name: 's_update_time_min',xtype: "datetimefield",columnWidth: 0.5},
				{fieldLabel: '截止更新时间', name: 's_update_time_max',xtype: "datetimefield",columnWidth: 0.5},
			]},
        ]
    }
});



//操作 
Ext.define('admin.config.updata', {
	extend: 'Tg.tx.Window',
	alias: 'widget.admin_Config_updata',
	requires: [
		'admin.config.CURDViewController',
		'admin.config.CURDViewModel',
	],
	controller: '_adminConfigController',
	viewModel: '_adminConfigViewModel',
    title:'配置 - 操作',
    items:{
    	xtype:'CURDForm',
        items:[
			{items: [
				{xtype:'textfield', fieldLabel: '标识', name: 'name', itemId: 'name', cls: '', columnWidth: 1, height: 30, readOnly: false, emptyText:'请输入...'},
			]},
			{items: [
				{xtype:'textfield', fieldLabel: '名称', name: 'title', itemId: 'title', cls: '', columnWidth: 1, height: 30, readOnly: false, emptyText:'请输入...'},
			]},
			{items: [
				{xtype:'combobox', fieldLabel: '分组', name: 'group', itemId: 'group', cls: '', columnWidth: 0.5, height: 30, readOnly: false, emptyText:'请选择...', editable:false, displayField:'text', valueField: 'value', store:{fields:['text','value'],data:_Dictionary['config_group']}},
			]},
			{items: [
				{xtype:'textarea', fieldLabel: '值', name: 'value', itemId: 'value', cls: '', columnWidth: 1, height: 30, readOnly: false, preventScrollbars:true, emptyText:'请输入...'},
			]},
			{items: [
				{xtype:'numberfield', fieldLabel: '排序', name: 'sort', itemId: 'sort', cls: '', columnWidth: 0.5, height: 30, readOnly: false, minValue:'0', maxValue:'999999', allowDecimals:false, decimalSeparator:'.'},
				{xtype:'combobox', fieldLabel: '状态', name: 'status', itemId: 'status', cls: '', columnWidth: 0.5, height: 30, readOnly: false, emptyText:'请选择', editable:false, displayField:'text', valueField: 'value', store:{fields:['text','value'],data:_Dictionary['sys_status']}},
			]},
			{items: [
				{xtype:'textarea', fieldLabel: '说明', name: 'remark', itemId: 'remark', cls: '', columnWidth: 1, height: 80, readOnly: false, preventScrollbars:true, emptyText:'请输入...'},
			]},
			{xtype:'hiddenfield', fieldLabel: '主键', name: 'id', itemId: 'id', cls: '', columnWidth: 1, height: 30, readOnly: false},
        ]
    }
});



//实例化
Ext.application({
	name: 'admin',
	extend: 'Ext.app.Application',
	autoCreateViewport: 'admin.config.index'
});
</script>

{/block}
